package com.cgtong.android.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.cgtong.android.R;
import com.cgtong.android.bean.ActivityBean;
import com.cgtong.android.widget.GlideApp;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

/**
 * Created by Sky.Bing on 2017/10/18.
 */

public class WonderfulActivityListAdapter extends BaseQuickAdapter<ActivityBean, BaseViewHolder> {
    private Context mContext;

    public WonderfulActivityListAdapter(Context context) {
        super(R.layout.adapter_wonderful_activities, null);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ActivityBean activityBean) {
        baseViewHolder.setText(R.id.activity_name, activityBean.getTitle());
        baseViewHolder.setText(R.id.activity_partcount, mContext.getResources().getString(R.string.txt_activity_join_total, activityBean.getHot_total()));
        switch (activityBean.getActivityState()) {  //1正在进行 2未开始  3已过期  0未知
            case 2:
                baseViewHolder.setText(R.id.parting_activity, "未开始");
                break;
            case 0:
            case 3:
                baseViewHolder.setText(R.id.parting_activity, "已结束");
                break;
            default:
                baseViewHolder.setText(R.id.parting_activity, "参与");
                break;
        }
        baseViewHolder.addOnClickListener(R.id.parting_activity);
        GlideApp.with(mContext).load(activityBean.getImg_url()).placeholder(R.drawable.icon_default_loading).error(R.drawable.icon_default_error)
                .into((ImageView) baseViewHolder.getView(R.id.activity_image));
    }
}